#ifndef USERORDERPAGE_H
#define USERORDERPAGE_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QTableWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QMessageBox>
#include <QDebug>
#include <QDateTime>
#include "database.h"

class UserOrderPage : public QWidget
{
    Q_OBJECT

public:
    explicit UserOrderPage(database &db, QWidget *parent = nullptr);
    ~UserOrderPage();
    void setUserInfo(int phoneId, int userIdentity);

private slots:
    void onConfirmReceiptClicked();
    void onCommentClicked(int row, int orderId, int comId, const QString &comName);

private:
    void setupUI();
    void loadUserOrders();
    QPushButton* createConfirmButton(int row, int orderId, const QString &status);
    QPushButton* createCommentButton(int row, int orderId, int comId, const QString &comName, bool commented);
    bool processOrderCompletion(int orderId);
    void showCommentDialog(int orderId, int comId, const QString &comName);

private:
    database &db;
    int userPhoneId;
    int userIdentity;
    QLabel *titleLabel;
    QPushButton *refreshButton;
    QTableWidget *ordersTable;
};

#endif // USERORDERPAGE_H 